﻿<common:LayoutAwarePage x:Class="StoreAppLibDemo.Examples.Converter.ConcatenationConverterPage"
                        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                        xmlns:ViewModel="using:StoreAppLibDemo.ViewModel"
                        xmlns:common="using:StoreAppLibDemo.Common"
                        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                        xmlns:local="using:StoreAppLibDemo.Examples.Converter"
                        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                        mc:Ignorable="d">
    <common:LayoutAwarePage.DataContext>
        <ViewModel:ConcatenationConverterPageView />
    </common:LayoutAwarePage.DataContext>


    <Grid Style="{StaticResource AppPageStyle}">
        <Grid.RowDefinitions>
            <RowDefinition Height="100" />
            <RowDefinition Height="40" />
            <RowDefinition />
            <RowDefinition Height="50" />
        </Grid.RowDefinitions>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Image Grid.Column="1"
                   Margin="0,0,50,0"
                   Source="ms-appx:///Assets/PageLogo.png" />
            <TextBlock Margin="120,0,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Bottom"
                       Style="{StaticResource HeaderTextStyle}"
                       Text="Concatenation Converter"
                       TextWrapping="Wrap" />
            <Button Margin="36,0,0,0"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Bottom"
                    Click="GoBack"
                    Content="Button"
                    Style="{StaticResource BackButtonStyle}" />

        </Grid>

        <TextBlock Grid.Row="3"
                   Margin="0,0,50,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Center"
                   FontSize="9"
                   Text="Copyright ©  2012 Suresh Kumar T" />
        <Grid Grid.Row="2" Margin="120,0,0,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="125" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="30" />
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <TextBlock Grid.ColumnSpan="2"
                       Style="{StaticResource BodyTextStyle}"
                       TextWrapping="Wrap">
                <Run>ConcatenationConverter concatenates a string property of all elements in a collection during data binding using specified separator between each value. The converter can concatenate property of elements within nested collections. Collection properties and separator should be declared as resource and passed as converter parameter.</Run>
                <LineBreak />
                <LineBreak />
                <Run>In this example distinct languages are displayed from the following collection hierarchy.</Run>

            </TextBlock>
            <Border Grid.Row="2"
                    Background="White"
                    BorderBrush="#002896"
                    BorderThickness="1" />
            <TextBlock Grid.Row="2"
                       Width="115"
                       Margin="5,0,0,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Style="{StaticResource BodyTextBlackStyle}"
                       Text="{Binding Company.Name}"
                       TextWrapping="Wrap" />
            <ItemsControl Grid.Row="2"
                          Grid.Column="1"
                          Grid.ColumnSpan="1"
                          Width="400"
                          HorizontalAlignment="Left"
                          ItemsSource="{Binding Company.Departments}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Grid Width="350" HorizontalAlignment="Left">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Border Grid.ColumnSpan="2"
                                    Background="White"
                                    BorderBrush="#002896"
                                    BorderThickness="1" />
                            <TextBlock Margin="5,0,0,0"
                                       HorizontalAlignment="Left"
                                       VerticalAlignment="Top"
                                       Style="{StaticResource BodyTextBlackStyle}"
                                       Text="{Binding Name}"
                                       TextWrapping="Wrap" />
                            <ItemsControl Grid.Column="1" ItemsSource="{Binding Employees}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition />
                                                <ColumnDefinition />
                                            </Grid.ColumnDefinitions>
                                            <Border Grid.ColumnSpan="2"
                                                    Background="White"
                                                    BorderBrush="#002896"
                                                    BorderThickness="1" />
                                            <TextBlock Margin="5,0,0,0"
                                                       HorizontalAlignment="Left"
                                                       VerticalAlignment="Top"
                                                       Style="{StaticResource BodyTextBlackStyle}"
                                                       Text="{Binding Name}"
                                                       TextWrapping="Wrap" />
                                            <ItemsControl Grid.Column="1" ItemsSource="{Binding Languages}">
                                                <ItemsControl.ItemTemplate>
                                                    <DataTemplate>
                                                        <Grid Height="25">
                                                            <Border HorizontalAlignment="Stretch"
                                                                    Background="White"
                                                                    BorderBrush="#002896"
                                                                    BorderThickness="1" />
                                                            <TextBlock Margin="5,0,0,0"
                                                                       HorizontalAlignment="Left"
                                                                       VerticalAlignment="Top"
                                                                       Style="{StaticResource BodyTextBlackStyle}"
                                                                       Text="{Binding Name}"
                                                                       TextWrapping="Wrap" />
                                                        </Grid>
                                                    </DataTemplate>
                                                </ItemsControl.ItemTemplate>
                                            </ItemsControl>
                                        </Grid>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </Grid>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>

            <TextBlock Grid.Row="3"
                       Grid.Column="0"
                       Grid.ColumnSpan="4"
                       Margin="0,20,0,0"
                       Style="{StaticResource BodyTextStyle}"
                       Text="Languages :" />
            <TextBlock Grid.Row="3"
                       Grid.Column="1"
                       Grid.ColumnSpan="4"
                       Margin="0,20,0,0"
                       Style="{StaticResource BodyTextStyle}"
                       Text="{Binding Company.Departments,
                                      Converter={StaticResource ConcatenationConverter},
                                      ConverterParameter={StaticResource LanguageConcatenationParameter}}" />
        </Grid>
    </Grid>
</common:LayoutAwarePage>